Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['item_code' => 'required|unique:products|max:255']);
     if ($validator->fails()) {
         return redirect('add-product')->withErrors($validator)->withInput();
     }
     $product_all = new Product($request->all());
     $product_all->save();
     if ($request->product_type == "Custom Cable") {
         foreach ($request->recipe_components as $key => $value) {
             if (!empty($value)) {
                 $cable_all = new Cable(array('product_name' => $product_all->item_code, 'recipe_components' => $value, 'recipe_desc' => $request->recipe_desc[$key], 'recipe_qty' => $request->recipe_qty[$key], 'recipe_mu' => $request->recipe_mu[$key]));
             }
             $cable_all->save();
         }
     }
     Mail::raw('New Prodcut ' . $product_all->item_code . ' is added by ' . $product_all->person_name . '', function ($message) {
         $message->from('*****@*****.**', 'NMK');
         $emails = ['*****@*****.**'];
         $message->to($emails)->cc('*****@*****.**')->subject('New Item');
     });
     return redirect('add-product')->with('message', 'Thank You! Successfully submitted.');
 }
Esempio n. 2
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
header('Access-Control-Allow-Origin: http://localhost');
header('Access-Control-Allow-Credentials: true');
Route::get('/', function () {
    return view('admin/roadshows_nmk');
});
/* API Calls to Application */
Route::get('products/api/{id}', function ($id) {
    $product = DB::table('products')->find($id);
    if ($product->product_type == "Custom Cable") {
        $cables = Cable::where('product_name', $product->item_code)->get();
        return Response::json(array($product, $cables));
    } else {
        return Response::json(array($product));
    }
});
Route::get('/main-page', function () {
    return view('admin/nmk-main');
});
Route::get('/add-product', function () {
    return view('admin/products');
});
Route::get('/nmk-customer', function () {
    return view('admin/nmk-customer');
});
Route::get('/roadshow-nmk', function () {