Passed
Push — master ( 4e0c2f...af0465 )
by Prateek
04:42 queued 02:26
created

View::getHeadings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
namespace Prateekkarki\Laragen\Generators\Backend;
3
4
use Prateekkarki\Laragen\Generators\BaseGenerator;
5
use Prateekkarki\Laragen\Generators\GeneratorInterface;
6
7
class View extends BaseGenerator implements GeneratorInterface
8
{
9
    public function generate()
10
    {
11
		$viewsToBeGenerated = ['index']; // To be generated dynamically
12
13
		$generatedFiles = [];
14
		
15
        foreach ($viewsToBeGenerated as $view) {
16
            $viewTemplate = $this->buildTemplate('Backend/Views/' . $view, [
17
				'{{headings}}' 			 => $this->getHeadings(),
18
                '{{modelNameLowercase}}' => str_singular($this->module->getModuleName()),
0 ignored issues
show
Deprecated Code introduced by
The function str_singular() has been deprecated: Str::singular() should be used directly instead. Will be removed in Laravel 5.9. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
                '{{modelNameLowercase}}' => /** @scrutinizer ignore-deprecated */ str_singular($this->module->getModuleName()),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
19
                '{{moduleName}}'         => $this->module->getModuleName()
20
            ]);
21
22
            $fullFilePath = $this->getPath("resources/views/backend/" . $this->module->getModuleName()) . "/{$view}.blade.php";
23
            file_put_contents($fullFilePath, $viewTemplate);
24
            $generatedFiles[] =  $fullFilePath;
25
        }
26
27
        $mainMenuFile = $this->getPath("resources/views/backend/includes/")."main_menu.blade.php";
28
        $this->initializeFiles([
29
            $mainMenuFile => "Backend/Views/includes/main_menu",
30
        ]);
31
32
        $this->insertIntoFile(
33
            $mainMenuFile,
34
            "{{-- Main Menu --}}",
35
			""
36
		);
37
38
        return $generatedFiles;
39
	}
40
41
	public function getHeadings(){
42
        $columns = $this->module->getBackendColumnTitles();
43
        $headings= "";
44
        foreach ($columns as $column) {
45
            $headings .= "<th>".$column."</th>";
46
        }
47
		return $headings;
48
	}
49
}
50