| @@ 8-154 (lines=147) @@ | ||
| 5 | use App\Brand_Model; |
|
| 6 | use Illuminate\Http\Request; |
|
| 7 | ||
| 8 | class Brand_ModelController extends Controller |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Display a listing of the resource. |
|
| 12 | * |
|
| 13 | * @return \Illuminate\Http\Response |
|
| 14 | */ |
|
| 15 | public function __construct() |
|
| 16 | { |
|
| 17 | $this->middleware('auth'); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function index() |
|
| 21 | { |
|
| 22 | $brand_models = Brand_model::paginate(5); |
|
| 23 | ||
| 24 | return view('manteniments/brand_model/index', ['brand_models' => $brand_models]); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Show the form for creating a new resource. |
|
| 29 | * |
|
| 30 | * @return \Illuminate\Http\Response |
|
| 31 | */ |
|
| 32 | public function create() |
|
| 33 | { |
|
| 34 | return view('manteniments/brand_model/create'); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Store a newly created resource in storage. |
|
| 39 | * |
|
| 40 | * @param \Illuminate\Http\Request $request |
|
| 41 | * |
|
| 42 | * @return \Illuminate\Http\Response |
|
| 43 | */ |
|
| 44 | public function store(Request $request) |
|
| 45 | { |
|
| 46 | $this->validateInput($request); |
|
| 47 | Brand_model::create([ |
|
| 48 | 'name' => $request['name'], |
|
| 49 | 'description' => $request['description'], |
|
| 50 | ]); |
|
| 51 | ||
| 52 | return redirect()->intended('mnt/brand_model'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Display the specified resource. |
|
| 57 | * |
|
| 58 | * @param int $id |
|
| 59 | * |
|
| 60 | * @return \Illuminate\Http\Response |
|
| 61 | */ |
|
| 62 | public function show($id) |
|
| 63 | { |
|
| 64 | // |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Show the form for editing the specified resource. |
|
| 69 | * |
|
| 70 | * @param int $id |
|
| 71 | * |
|
| 72 | * @return \Illuminate\Http\Response |
|
| 73 | */ |
|
| 74 | public function edit($id) |
|
| 75 | { |
|
| 76 | $brand_model = Brand_model::find($id); |
|
| 77 | // Redirect to country list if updating country wasn't existed |
|
| 78 | if ($brand_model == null || count($brand_model) == 0) { |
|
| 79 | return redirect()->intended('/mnt/brand_model'); |
|
| 80 | } |
|
| 81 | ||
| 82 | return view('manteniments/brand_model/edit', ['brand_model' => $brand_model]); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Update the specified resource in storage. |
|
| 87 | * |
|
| 88 | * @param \Illuminate\Http\Request $request |
|
| 89 | * @param int $id |
|
| 90 | * |
|
| 91 | * @return \Illuminate\Http\Response |
|
| 92 | */ |
|
| 93 | public function update(Request $request, $id) |
|
| 94 | { |
|
| 95 | $brand_model = Brand_model::findOrFail($id); |
|
| 96 | $input = [ |
|
| 97 | 'name' => $request['name'], |
|
| 98 | 'description' => $request['description'], |
|
| 99 | ]; |
|
| 100 | $this->validate($request, [ |
|
| 101 | 'name' => 'required|max:60', |
|
| 102 | ]); |
|
| 103 | Brand_model::where('id', $id) |
|
| 104 | ->update($input); |
|
| 105 | ||
| 106 | return redirect()->intended('mnt/brand_model'); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Remove the specified resource from storage. |
|
| 111 | * |
|
| 112 | * @param int $id |
|
| 113 | * |
|
| 114 | * @return \Illuminate\Http\Response |
|
| 115 | */ |
|
| 116 | public function destroy($id) |
|
| 117 | { |
|
| 118 | Brand_model::where('id', $id)->delete(); |
|
| 119 | ||
| 120 | return redirect()->intended('mnt/brand_model'); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function search(Request $request) |
|
| 124 | { |
|
| 125 | $constraints = [ |
|
| 126 | 'name' => $request['name'], |
|
| 127 | ]; |
|
| 128 | $brand_models = $this->doSearchingQuery($constraints); |
|
| 129 | ||
| 130 | return view('manteniments/brand_model/index', ['brand_models' => $brand_models, 'searchingVals' => $constraints]); |
|
| 131 | } |
|
| 132 | ||
| 133 | private function doSearchingQuery($constraints) |
|
| 134 | { |
|
| 135 | $query = brand_model::query(); |
|
| 136 | $fields = array_keys($constraints); |
|
| 137 | $index = 0; |
|
| 138 | foreach ($constraints as $constraint) { |
|
| 139 | if ($constraint != null) { |
|
| 140 | $query = $query->where($fields[$index], 'like', '%'.$constraint.'%'); |
|
| 141 | } |
|
| 142 | $index++; |
|
| 143 | } |
|
| 144 | ||
| 145 | return $query->paginate(5); |
|
| 146 | } |
|
| 147 | ||
| 148 | private function validateInput($request) |
|
| 149 | { |
|
| 150 | $this->validate($request, [ |
|
| 151 | 'name' => 'required|max:60|unique:provider', |
|
| 152 | ]); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| @@ 8-154 (lines=147) @@ | ||
| 5 | use App\Material_Type; |
|
| 6 | use Illuminate\Http\Request; |
|
| 7 | ||
| 8 | class Material_TypeController extends Controller |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Display a listing of the resource. |
|
| 12 | * |
|
| 13 | * @return \Illuminate\Http\Response |
|
| 14 | */ |
|
| 15 | public function __construct() |
|
| 16 | { |
|
| 17 | $this->middleware('auth'); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function index() |
|
| 21 | { |
|
| 22 | $material_types = Material_type::paginate(5); |
|
| 23 | ||
| 24 | return view('manteniments/material_type/index', ['material_types' => $material_types]); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Show the form for creating a new resource. |
|
| 29 | * |
|
| 30 | * @return \Illuminate\Http\Response |
|
| 31 | */ |
|
| 32 | public function create() |
|
| 33 | { |
|
| 34 | return view('manteniments/material_type/create'); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Store a newly created resource in storage. |
|
| 39 | * |
|
| 40 | * @param \Illuminate\Http\Request $request |
|
| 41 | * |
|
| 42 | * @return \Illuminate\Http\Response |
|
| 43 | */ |
|
| 44 | public function store(Request $request) |
|
| 45 | { |
|
| 46 | $this->validateInput($request); |
|
| 47 | Material_type::create([ |
|
| 48 | 'name' => $request['name'], |
|
| 49 | 'description' => $request['description'], |
|
| 50 | ]); |
|
| 51 | ||
| 52 | return redirect()->intended('mnt/material_type'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Display the specified resource. |
|
| 57 | * |
|
| 58 | * @param int $id |
|
| 59 | * |
|
| 60 | * @return \Illuminate\Http\Response |
|
| 61 | */ |
|
| 62 | public function show($id) |
|
| 63 | { |
|
| 64 | // |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Show the form for editing the specified resource. |
|
| 69 | * |
|
| 70 | * @param int $id |
|
| 71 | * |
|
| 72 | * @return \Illuminate\Http\Response |
|
| 73 | */ |
|
| 74 | public function edit($id) |
|
| 75 | { |
|
| 76 | $material_type = Material_type::find($id); |
|
| 77 | // Redirect to country list if updating country wasn't existed |
|
| 78 | if ($material_type == null || count($material_type) == 0) { |
|
| 79 | return redirect()->intended('/mnt/material_type'); |
|
| 80 | } |
|
| 81 | ||
| 82 | return view('manteniments/material_type/edit', ['material_type' => $material_type]); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Update the specified resource in storage. |
|
| 87 | * |
|
| 88 | * @param \Illuminate\Http\Request $request |
|
| 89 | * @param int $id |
|
| 90 | * |
|
| 91 | * @return \Illuminate\Http\Response |
|
| 92 | */ |
|
| 93 | public function update(Request $request, $id) |
|
| 94 | { |
|
| 95 | $material_type = Material_type::findOrFail($id); |
|
| 96 | $input = [ |
|
| 97 | 'name' => $request['name'], |
|
| 98 | 'description' => $request['description'], |
|
| 99 | ]; |
|
| 100 | $this->validate($request, [ |
|
| 101 | 'name' => 'required|max:60', |
|
| 102 | ]); |
|
| 103 | Material_type::where('id', $id) |
|
| 104 | ->update($input); |
|
| 105 | ||
| 106 | return redirect()->intended('mnt/material_type'); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Remove the specified resource from storage. |
|
| 111 | * |
|
| 112 | * @param int $id |
|
| 113 | * |
|
| 114 | * @return \Illuminate\Http\Response |
|
| 115 | */ |
|
| 116 | public function destroy($id) |
|
| 117 | { |
|
| 118 | Material_type::where('id', $id)->delete(); |
|
| 119 | ||
| 120 | return redirect()->intended('mnt/material_type'); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function search(Request $request) |
|
| 124 | { |
|
| 125 | $constraints = [ |
|
| 126 | 'name' => $request['name'], |
|
| 127 | ]; |
|
| 128 | $material_types = $this->doSearchingQuery($constraints); |
|
| 129 | ||
| 130 | return view('manteniments/material_type/index', ['material_types' => $material_types, 'searchingVals' => $constraints]); |
|
| 131 | } |
|
| 132 | ||
| 133 | private function doSearchingQuery($constraints) |
|
| 134 | { |
|
| 135 | $query = material_type::query(); |
|
| 136 | $fields = array_keys($constraints); |
|
| 137 | $index = 0; |
|
| 138 | foreach ($constraints as $constraint) { |
|
| 139 | if ($constraint != null) { |
|
| 140 | $query = $query->where($fields[$index], 'like', '%'.$constraint.'%'); |
|
| 141 | } |
|
| 142 | $index++; |
|
| 143 | } |
|
| 144 | ||
| 145 | return $query->paginate(5); |
|
| 146 | } |
|
| 147 | ||
| 148 | private function validateInput($request) |
|
| 149 | { |
|
| 150 | $this->validate($request, [ |
|
| 151 | 'name' => 'required|max:60|unique:provider', |
|
| 152 | ]); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| @@ 8-154 (lines=147) @@ | ||
| 5 | use App\Brand_Model; |
|
| 6 | use Illuminate\Http\Request; |
|
| 7 | ||
| 8 | class Brand_ModelController extends Controller |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Display a listing of the resource. |
|
| 12 | * |
|
| 13 | * @return \Illuminate\Http\Response |
|
| 14 | */ |
|
| 15 | public function __construct() |
|
| 16 | { |
|
| 17 | $this->middleware('auth'); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function index() |
|
| 21 | { |
|
| 22 | $brand_models = Brand_model::paginate(5); |
|
| 23 | ||
| 24 | return view('manteniments/brand_model/index', ['brand_models' => $brand_models]); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Show the form for creating a new resource. |
|
| 29 | * |
|
| 30 | * @return \Illuminate\Http\Response |
|
| 31 | */ |
|
| 32 | public function create() |
|
| 33 | { |
|
| 34 | return view('manteniments/brand_model/create'); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Store a newly created resource in storage. |
|
| 39 | * |
|
| 40 | * @param \Illuminate\Http\Request $request |
|
| 41 | * |
|
| 42 | * @return \Illuminate\Http\Response |
|
| 43 | */ |
|
| 44 | public function store(Request $request) |
|
| 45 | { |
|
| 46 | $this->validateInput($request); |
|
| 47 | Brand_model::create([ |
|
| 48 | 'name' => $request['name'], |
|
| 49 | 'description' => $request['description'], |
|
| 50 | ]); |
|
| 51 | ||
| 52 | return redirect()->intended('mnt/brand_model'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Display the specified resource. |
|
| 57 | * |
|
| 58 | * @param int $id |
|
| 59 | * |
|
| 60 | * @return \Illuminate\Http\Response |
|
| 61 | */ |
|
| 62 | public function show($id) |
|
| 63 | { |
|
| 64 | // |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Show the form for editing the specified resource. |
|
| 69 | * |
|
| 70 | * @param int $id |
|
| 71 | * |
|
| 72 | * @return \Illuminate\Http\Response |
|
| 73 | */ |
|
| 74 | public function edit($id) |
|
| 75 | { |
|
| 76 | $brand_model = Brand_model::find($id); |
|
| 77 | // Redirect to country list if updating country wasn't existed |
|
| 78 | if ($brand_model == null || count($brand_model) == 0) { |
|
| 79 | return redirect()->intended('/mnt/brand_model'); |
|
| 80 | } |
|
| 81 | ||
| 82 | return view('manteniments/brand_model/edit', ['brand_model' => $brand_model]); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Update the specified resource in storage. |
|
| 87 | * |
|
| 88 | * @param \Illuminate\Http\Request $request |
|
| 89 | * @param int $id |
|
| 90 | * |
|
| 91 | * @return \Illuminate\Http\Response |
|
| 92 | */ |
|
| 93 | public function update(Request $request, $id) |
|
| 94 | { |
|
| 95 | $brand_model = Brand_model::findOrFail($id); |
|
| 96 | $input = [ |
|
| 97 | 'name' => $request['name'], |
|
| 98 | 'description' => $request['description'], |
|
| 99 | ]; |
|
| 100 | $this->validate($request, [ |
|
| 101 | 'name' => 'required|max:60', |
|
| 102 | ]); |
|
| 103 | Brand_model::where('id', $id) |
|
| 104 | ->update($input); |
|
| 105 | ||
| 106 | return redirect()->intended('mnt/brand_model'); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Remove the specified resource from storage. |
|
| 111 | * |
|
| 112 | * @param int $id |
|
| 113 | * |
|
| 114 | * @return \Illuminate\Http\Response |
|
| 115 | */ |
|
| 116 | public function destroy($id) |
|
| 117 | { |
|
| 118 | Brand_model::where('id', $id)->delete(); |
|
| 119 | ||
| 120 | return redirect()->intended('mnt/brand_model'); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function search(Request $request) |
|
| 124 | { |
|
| 125 | $constraints = [ |
|
| 126 | 'name' => $request['name'], |
|
| 127 | ]; |
|
| 128 | $brand_models = $this->doSearchingQuery($constraints); |
|
| 129 | ||
| 130 | return view('manteniments/brand_model/index', ['brand_models' => $brand_models, 'searchingVals' => $constraints]); |
|
| 131 | } |
|
| 132 | ||
| 133 | private function doSearchingQuery($constraints) |
|
| 134 | { |
|
| 135 | $query = brand_model::query(); |
|
| 136 | $fields = array_keys($constraints); |
|
| 137 | $index = 0; |
|
| 138 | foreach ($constraints as $constraint) { |
|
| 139 | if ($constraint != null) { |
|
| 140 | $query = $query->where($fields[$index], 'like', '%'.$constraint.'%'); |
|
| 141 | } |
|
| 142 | $index++; |
|
| 143 | } |
|
| 144 | ||
| 145 | return $query->paginate(5); |
|
| 146 | } |
|
| 147 | ||
| 148 | private function validateInput($request) |
|
| 149 | { |
|
| 150 | $this->validate($request, [ |
|
| 151 | 'name' => 'required|max:60|unique:provider', |
|
| 152 | ]); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| @@ 8-154 (lines=147) @@ | ||
| 5 | use App\Material_Type; |
|
| 6 | use Illuminate\Http\Request; |
|
| 7 | ||
| 8 | class Material_TypeController extends Controller |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Display a listing of the resource. |
|
| 12 | * |
|
| 13 | * @return \Illuminate\Http\Response |
|
| 14 | */ |
|
| 15 | public function __construct() |
|
| 16 | { |
|
| 17 | $this->middleware('auth'); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function index() |
|
| 21 | { |
|
| 22 | $material_types = Material_type::paginate(5); |
|
| 23 | ||
| 24 | return view('manteniments/material_type/index', ['material_types' => $material_types]); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Show the form for creating a new resource. |
|
| 29 | * |
|
| 30 | * @return \Illuminate\Http\Response |
|
| 31 | */ |
|
| 32 | public function create() |
|
| 33 | { |
|
| 34 | return view('manteniments/material_type/create'); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Store a newly created resource in storage. |
|
| 39 | * |
|
| 40 | * @param \Illuminate\Http\Request $request |
|
| 41 | * |
|
| 42 | * @return \Illuminate\Http\Response |
|
| 43 | */ |
|
| 44 | public function store(Request $request) |
|
| 45 | { |
|
| 46 | $this->validateInput($request); |
|
| 47 | Material_type::create([ |
|
| 48 | 'name' => $request['name'], |
|
| 49 | 'description' => $request['description'], |
|
| 50 | ]); |
|
| 51 | ||
| 52 | return redirect()->intended('mnt/material_type'); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Display the specified resource. |
|
| 57 | * |
|
| 58 | * @param int $id |
|
| 59 | * |
|
| 60 | * @return \Illuminate\Http\Response |
|
| 61 | */ |
|
| 62 | public function show($id) |
|
| 63 | { |
|
| 64 | // |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Show the form for editing the specified resource. |
|
| 69 | * |
|
| 70 | * @param int $id |
|
| 71 | * |
|
| 72 | * @return \Illuminate\Http\Response |
|
| 73 | */ |
|
| 74 | public function edit($id) |
|
| 75 | { |
|
| 76 | $material_type = Material_type::find($id); |
|
| 77 | // Redirect to country list if updating country wasn't existed |
|
| 78 | if ($material_type == null || count($material_type) == 0) { |
|
| 79 | return redirect()->intended('/mnt/material_type'); |
|
| 80 | } |
|
| 81 | ||
| 82 | return view('manteniments/material_type/edit', ['material_type' => $material_type]); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Update the specified resource in storage. |
|
| 87 | * |
|
| 88 | * @param \Illuminate\Http\Request $request |
|
| 89 | * @param int $id |
|
| 90 | * |
|
| 91 | * @return \Illuminate\Http\Response |
|
| 92 | */ |
|
| 93 | public function update(Request $request, $id) |
|
| 94 | { |
|
| 95 | $material_type = Material_type::findOrFail($id); |
|
| 96 | $input = [ |
|
| 97 | 'name' => $request['name'], |
|
| 98 | 'description' => $request['description'], |
|
| 99 | ]; |
|
| 100 | $this->validate($request, [ |
|
| 101 | 'name' => 'required|max:60', |
|
| 102 | ]); |
|
| 103 | Material_type::where('id', $id) |
|
| 104 | ->update($input); |
|
| 105 | ||
| 106 | return redirect()->intended('mnt/material_type'); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Remove the specified resource from storage. |
|
| 111 | * |
|
| 112 | * @param int $id |
|
| 113 | * |
|
| 114 | * @return \Illuminate\Http\Response |
|
| 115 | */ |
|
| 116 | public function destroy($id) |
|
| 117 | { |
|
| 118 | Material_type::where('id', $id)->delete(); |
|
| 119 | ||
| 120 | return redirect()->intended('mnt/material_type'); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function search(Request $request) |
|
| 124 | { |
|
| 125 | $constraints = [ |
|
| 126 | 'name' => $request['name'], |
|
| 127 | ]; |
|
| 128 | $material_types = $this->doSearchingQuery($constraints); |
|
| 129 | ||
| 130 | return view('manteniments/material_type/index', ['material_types' => $material_types, 'searchingVals' => $constraints]); |
|
| 131 | } |
|
| 132 | ||
| 133 | private function doSearchingQuery($constraints) |
|
| 134 | { |
|
| 135 | $query = material_type::query(); |
|
| 136 | $fields = array_keys($constraints); |
|
| 137 | $index = 0; |
|
| 138 | foreach ($constraints as $constraint) { |
|
| 139 | if ($constraint != null) { |
|
| 140 | $query = $query->where($fields[$index], 'like', '%'.$constraint.'%'); |
|
| 141 | } |
|
| 142 | $index++; |
|
| 143 | } |
|
| 144 | ||
| 145 | return $query->paginate(5); |
|
| 146 | } |
|
| 147 | ||
| 148 | private function validateInput($request) |
|
| 149 | { |
|
| 150 | $this->validate($request, [ |
|
| 151 | 'name' => 'required|max:60|unique:provider', |
|
| 152 | ]); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||