mehmetanbaki

mehmetanbaki

Full Stack Developer at Iraq, Baghdad

Member Since 3 Months Ago

Toronto

Experience Points
47,390
Total
Experience

2,610 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
381
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 10
47,390 XP
Feb
22
6 days ago
Activity icon

Replied to Different Table Auth

@jlrdw

I do this just the problem I integrate them with stripe payment method so I want to throwing the admin and the sub-admin away from the payment I thought it'll be better if I make another table to give it only to the payment members

Activity icon

Started a new Conversation Different Table Auth

Hay Laravelers

Can I use another table besides the users table and give it middleware too such as members table to make them go to another dashboard is that possible ??

Feb
21
1 week ago
Activity icon

Started a new Conversation JWT Laravel 6

Hey Laravelers

I want to add token bearer to my users by using middleware as you know the migrations gave me empty token so how can I do it please ??

Feb
18
1 week ago
Activity icon

Started a new Conversation Pin Authentication

Hey Laravelers

I want to make login with mobile phone number without password and after entering the phone the second step will be sending pin code to phone number to login after that will route the login to the role that I gave it to that number such as admin or user. I try to do that with passport but it didn't working???

any one can help me out with that ???

Feb
15
1 week ago
Activity icon

Replied to Version Bugs

@a4ashraf

It giving me that error

Activity icon

Replied to Version Bugs

@a4ashraf

the import model and controller i'ts above with the question and the is the eloquent model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class People extends Model
{
    public $table = 'people';
}
Activity icon

Replied to Version Bugs

@a4ashraf

I import them from excel sheet using laravel-excel package as you can see I try to create fields dynamically as it is with excel sheet how could I input name of the table and name of the fields if it's dynamic

Activity icon

Replied to Version Bugs

@a4ashraf what do you mean of translation and I'm use it but this error show :

ErrorException
Undefined variable: table_name 
Activity icon

Started a new Conversation Version Bugs

Hey Laravelers I have this issue

Symfony\Component\Debug\Exception\FatalThrowableError
syntax error, unexpected ';', expecting ']' 

this is the code:

<?php

namespace App\Http\Controllers;

use App\People;
use DB;
use Illuminate\Http\Request;
use App\Exports\PeopleExport;
use App\Imports\PeopleImport;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;


class PeopleController extends Controller
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function view()
    {
        $tables = DB::select('SHOW TABLES');
        return view('view', [ 'tables' => $tables ]);
    }

    /**
    * @return \Illuminate\Support\Collection
    */
    public function export()
    {
        return Excel::download(new PeopleExport, 'people.xlsx');
    }

    /**
    * @return \Illuminate\Support\Collection
    */
    public function import()
    {
        $data = Excel::import(new PeopleImport,request()->file('file'));
        foreach($data->toArray() as $row) {
            $value[] = $row;
            foreach($row as $key => $val) {
                $fields[] = $key;
            }
        }
    $ff = array_unique($fields);

        return back()->withStatus(['تم الرفع']);
    }
}

this is the model

<?php

namespace App\Imports;

use DB;
use App\People;
use Maatwebsite\Excel\Concerns\ToModel;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class PeopleImport implements ToModel
{
    // importing excel sheet or creating new schema

    public function model(array $row)
    {
        return new People([
            if (!Schema::hasTable($table_name))
            {
                Schema::connection('mysql')->create($table_name, function (Blueprint $table) use ($ff, $table_name) {
                    if (count($ff) > 0) {
                        foreach ($ff as $field) {
                            $table->longText($field)->nullable();
                            $array[] = $field;
                        }
                    }
                });
            }
        ]);
    }
}


Feb
11
2 weeks ago
Activity icon

Started a new Conversation Integrating Api From Another App

Hey larverlers

I want to integrating api from another application with my laravel application how can I do that ???

Feb
10
2 weeks ago
Activity icon

Started a new Conversation Mailhog

Hey Laravelers

I'm running the mailhog on my localhost and I'm running this command:

localhost:8025

but it's not working and by the way I'm taking it all from laravel official documentations

Feb
08
2 weeks ago
Activity icon

Replied to Reading Documentations

@jlrdw

laravel-excel

I understand how to work but couldn't make it on a real application. didn't understand why

Feb
07
3 weeks ago
Activity icon

Started a new Conversation Reading Documentations

Hey Everyone

I have problem with reading documentations for some packages of plugins I couldn't understand anything of them and it's so confusing because there is no videos about them the make it clear.

how can I deal with that problem

Activity icon

Replied to Controller

@fylzero it's work but why didn't accept id and name

Activity icon

Replied to Controller

@fylzero

As you can see I'm using it just when I changed the store, update and destroy functions it's gave me that error

Activity icon

Replied to Controller

@rymercyble

this appears to me with index blade

Activity icon

Started a new Conversation Controller

Hey Laravelers

I have this issue

Illuminate\Database\QueryException
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `name`, `bookings_users`.`booking_id` as `pivot_booking_id`, `bookings_users`.`user_id` as `pivot_user_id`, `bookings_users`.`created_at` as `pivot_created_at`, `bookings_users`.`updated_at` as `pivot_updated_at` from `users` inner join `bookings_users` on `users`.`id` = `bookings_users`.`user_id` where `bookings_users`.`booking_id` in (2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) 

this is the controller

<?php

namespace App\Http\Controllers;

use App\Booking;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class BookingController extends Controller
{

    public function index()
    {
        $bookings = Booking::with(['room.roomType', 'users:id,name'])->paginate(10);
        return view('bookings.index')
            ->with('bookings', $bookings);
    }


    public function create()
    {
        $users = DB::table('users')->get()->pluck('name', 'id')->prepend('none');
        $rooms = DB::table('rooms')->get()->pluck('number', 'id');
        return view('bookings.create')
            ->with('users', $users)
            ->with('booking', (new Booking()))
            ->with('rooms', $rooms);
    }


    public function store(Request $request)
    {
        $booking = Booking::create($request->input());
        $booking->users->attach($request->input('user_id'));

        return redirect()->action('[email protected]');
    }


    public function show(Booking $booking)
    {
        return view('bookings.show', ['booking' => $booking]);
    }


    public function edit(Booking $booking)
    {
        $users = DB::table('users')->get()->pluck('name', 'id')->prepend('none');
        $rooms = DB::table('rooms')->get()->pluck('number', 'id');
        $bookingsUser = DB::table('bookings_users')->where('booking_id', $booking->id)->first();
        return view('bookings.edit')
            ->with('bookingsUser', $bookingsUser)
            ->with('users', $users)
            ->with('rooms', $rooms)
            ->with('booking', $booking);
    }


    public function update(Request $request, Booking $booking)
    {
        $booking->fill($request->input());
        $booking->save();
        $booking->users()->sync([$request->input('user_id')]);
        return redirect()->action('[email protected]');
    }


    public function destroy(Booking $booking)
    {
        $booking->users()->detach();
        $booking->delete();
        return redirect()->action('[email protected]');
    }
}


Feb
06
3 weeks ago
Activity icon

Started a new Conversation Creating Dynamic Table

Hey Laravelers

Can I create table dynamically from the front view without get back to the models or controllers

Feb
04
3 weeks ago
Activity icon

Started a new Conversation Response Error

Hey laravelers

I have this controlls


<?php

namespace App\Http\Controllers;
use App\Http\Resources\Material\MaterialResource;
use App\Http\Requests\MaterialRequest;
use App\Model\Material;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class MaterialController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        return MaterialResource::collection(Material::all());
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(MaterialRequest $request)
    {
        //
        $material = new Material;
        $material->name = $request->name;
        $material->code = $request->code;
        $material->quantity = $request->quantity;
        $material->price = $request->price;
        $material->madein = $request->madein;
        $material->dateadd = $request->dateadd;
        $material->extraInfo = $request->extraInfo;
        $material->save();
        return response([
            'data' => new MaterialResource($material)
        ],Response::HTTP_CREATED);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Model\Material  $material
     * @return \Illuminate\Http\Response
     */
    public function show(Material $material)
    {
        //
         //return $material;
         return new MaterialResource($material);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Model\Material  $material
     * @return \Illuminate\Http\Response
     */
    public function edit(Material $material)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Model\Material  $material
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Material $material)
    {
        $out = ($request->quantity + $material->quantity);//add some
    
        $request->quantity=$out;
        return $out;

        $material->update($request->get());
        return response([
        'data' => new MaterialResource($material)
        ],Response::HTTP_CREATED); 

     
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Model\Material  $material
     * @return \Illuminate\Http\Response
     */
    public function destroy(Material $material)
    {
        //
        $material->delete();
        return 'item deleted';
    }
}


didn't give me the total in database table

Activity icon

Started a new Conversation SQL

Hey Laravelers

Can I use this query:

select * from * 

which means

select all tables from all databases

and if it's possible how could I do it

Feb
03
3 weeks ago
Activity icon

Started a new Conversation Public Function

Hey Laravelers

how could I put public function inside if statement, take a look: is that right ??

<?php

namespace App\Http\Controllers;

use App\People;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use App\Exports\PeopleExport;
use App\Imports\PeopleImport;
use Maatwebsite\Excel\Facades\Excel;

class PeopleController extends Controller
{

    public function index()
    {
        $people = People::all();

        return view('people')->with('people', $people);
    }

    public function import(Request $request)
    {
        if ($request->file('imported_file'))
        {
            Excel::import(new PeopleImport(), request()->file('imported_file'));
            if (!isset('imported_file'))
            {
                public function createTable($table_name, $fields = [])
                {
                    if (!Schema::hasTable($table_name)) {
                        Schema::create($table_name, function (Blueprint $table) use ($fields, $table_name) {
                            $table->increments('id');
                            if (count($fields) > 0) {
                                foreach ($fields as $field) {
                                    $table->{$field['type']}($field['name']);
                                }
                            }
                            $table->timestamps();
                        });
                    }
                }
            }
            return back();
        }
    }

    public function export()
    {
        return Excel::download(new PeopleExport(), 'people.xlsx');
    }

}

Activity icon

Replied to Big Error Import

@ahmeddabak

I'm trying to do this importing file first compared it with the data the contains in my model and after that adding the new data to my table if it's not exist that first step

second step creating table if it's not exist as you can see here

        public function createTable($table_name, $fields = [])
        {
            if (!Schema::hasTable($table_name)) {
                Schema::create($table_name, function (Blueprint $table) use ($fields, $table_name) {
                    $table->increments('id');
                    if (count($fields) > 0) {
                        foreach ($fields as $field) {
                            $table->{$field['type']}($field['name']);
                        }
                    }
                    $table->timestamps();
                });
            }
        }

this to create a table if it's not exist

Activity icon

Replied to Big Error Import

@ahmeddabak Ok that if I know what I'm importing but I'm importing random file and I don't know what's in it, So how could I do that ??

Activity icon

Started a new Conversation Big Error Import

Hey Laravelers:

this is my code and I don't know how to fix it:

I try to create a table in the database when I import it I'm using laravel-excel

this is import-model:


<?php

namespace App\Imports;

use App\People;
use Maatwebsite\Excel\Row;
use Maatwebsite\Excel\Concerns\OnEachRow;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;


class PeopleIMport implements OnEachRow
{

        public function onRow(Row $row)
        {
            People::firstOrCreate($row->toArray());
        }
        public function createTable($table_name, $fields = [])
        {
            if (!Schema::hasTable($table_name)) {
                Schema::create($table_name, function (Blueprint $table) use ($fields, $table_name) {
                    $table->increments('id');
                    if (count($fields) > 0) {
                        foreach ($fields as $field) {
                            $table->{$field['type']}($field['name']);
                        }
                    }
                    $table->timestamps();
                });
            }
        }

}


this is the controller:


<?php

namespace App\Http\Controllers;

use App\People;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use App\Exports\PeopleExport;
use App\Imports\PeopleImport;
use Maatwebsite\Excel\Facades\Excel;

class PeopleController extends Controller
{

    public function index()
    {
        $people = People::all();

        return view('people')->with('people', $people);
    }


    public function import(Request $request)
    {
        if ($request->file('imported_file')) {
            Excel::import(new PeopleImport(), request()->file('imported_file'));
            return back();
        }
    }

    public function export()
    {
        return Excel::download(new PeopleExport(), 'people.xlsx');
    }

}


this is the error:


Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' (SQL: select * from `people` where (`0` = semester and `1` = Industry and `2` = Data Base Name and `3` = Data Source and `4` = Data Base Description and `5` = Database Url and `6` = Data Dictionary Yes or No or Something? and `7` = Number of Rows and `8` = Number of Continous Variables and `9` = Number of Categorical Variables and `10` = Report (1) or Raw Data? (10) 1-10 scale and `11` = Comments) limit 1)
http://localhost:8000/people/import
Hide solutions
A column was not found

You might have forgotten to run your migrations. You can run your migrations using php artisan migrate.

Pressing the button below will try to run your migrations.
Read more

Run migrations

    Database: Running Migrations docs

what I'm trying to do importing randomly excel sheet

Activity icon

Replied to Table View

@tisuchi Ok, but how can view it how can it know it I mean columns it should be dynamically all columns for head and body

Activity icon

Replied to Table View

@tisuchi this is just explain how to get it in the model and controller I want it in the blade page as you can see in the question

Activity icon

Replied to Table View

@tisuchi I want to put something get all the heads for all the columns and put something in the body put all the body columns without write every row code

Activity icon

Started a new Conversation Table View

Hey Laravelers

Can I do code like bring the data from table and view it with foreach loop without getting anything static which means this :

@foreach($users as $user)

    <table>
        <th>{{ head }}</th>
        <td>{{ body }}</td>
    </table>

@endforeach

` ` ` 

what I mean it is getting all the data even if doesn't mention them or it will get what I have with the table ???
Activity icon

Replied to OnEachRow

@sinnbeck Which means it has two different tables and two different indexes one for users and one for groups right???

Activity icon

Replied to OnEachRow

@roborobok I’m sorry but still confusing to me

Feb
02
3 weeks ago
Activity icon

Replied to OnEachRow

@roborobok What is that means exactly ???

Activity icon

Started a new Conversation OnEachRow

Can any one explain this please:

`

namespace App\Imports;

use App\Group; use App\User; use Maatwebsite\Excel\Row; use Maatwebsite\Excel\Concerns\OnEachRow;

class UsersImport implements OnEachRow { public function onRow(Row $row) { $rowIndex = $row->getIndex(); $row = $row->toArray();

    $group = Group::firstOrCreate([
        'name' => $row[1],
    ]);

    $group->users()->create([
        'name' => $row[0],
    ]);
}

}

`

Activity icon

Replied to Adding Dynamic Fields

@kevinbui Ok I’ll try it now And what if want use toArray() method to read the excel file is there any problem ??

Activity icon

Replied to Reading Import Excel

@kevinbui I mean is that code will start the excel even if it doesn’t know columns and it will start by the name column???

Activity icon

Started a new Conversation Reading Import Excel

Hey Laravelers

look at this code:

namespace App\Imports;

use App\User;
use Maatwebsite\Excel\Concerns\ToModel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\WithChunkReading;

class UsersImport implements ToModel, WithChunkReading, ShouldQueue
{
    public function model(array $row)
    {
        return new User([
            'name' => $row[0],
        ]);
    }
    
    public function chunkSize(): int
    {
        return 1000;
    }
}

is that means you can read all the fields in the table even if it put only name in the array ??

Activity icon

Started a new Conversation Adding Dynamic Fields

I'm using this but it's not work

 namespace App\Imports;

 use App\User;
 use Maatwebsite\Excel\Concerns\ToModel;
 use Maatwebsite\Excel\Concerns\WithBatchInserts;

 class UsersImport implements ToModel, WithBatchInserts
 {
    public function model(array $row)
   {
       return new User([
           'name' => $row[0],
            if(!isset($row)){
              $row => $row[],
            }
      ]);
   }

}

I'm using the if to add fields from excel to database table if it's not exist is that correct ?? and if it's not how can I do it. By the way I'm using laravel-excle

Activity icon

Commented on Core Concepts: Middleware

@poboy You can use Policies/Gates or you can use Guards or may be you can use passport which it's totally recommended by laravel and it's so easy and cool

Activity icon

Replied to Importing Table

@armancodes that's just fetching the data from the database I want to import excel file and mapping it with the database table if the field is exist already it will update the data in it but if the field does not exist it will create new field and add it to the database table dynamically and incrementally???

and you can see I'm using laravel-excel package

Activity icon

Started a new Conversation Laravel-excel

Hey Laravelers

I know I asked a lot about this subject but I want to get solutions so let's say I have table and I want to import a excel sheer or csv file and I want to mapping the data with the table if the field is already in the table it will keep it and update the data but if the field does not exist it will create a field and add it to the database.

Is it clear or should I have to be more specific ??

Activity icon

Replied to Pathinfo()

@ahmeddabak where in web.php it's just for routes !!!!!

Activity icon

Started a new Conversation Pathinfo()

Hey Laravelers

I have this issue:

ErrorException
pathinfo() expects parameter 1 to be string, object given 

this is the controller

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Session;
use Maatwebsite\Excel\Facades\Excel;
use File;

class PeopleController extends Controller
{
    public function index()
    {
    return view('add-person');
    }

    public function import(Request $request){
        //validate the xls file
        $this->validate($request, array(
        'file'      => 'required'
        ));

        if($request->hasFile('file')){
        $extension = File::extension($request->file->getClientOriginalName());

            if ($extension == "xlsx" || $extension == "xls" || $extension == "csv") {

                        $path = $request->file->getRealPath();
                        $data = Excel::import($path, function($reader) {
                        })->get();
                        if(!empty($data) && $data->count()){

                        foreach ($data as $key => $value) {
                        $insert[] = [
                        'name' => $value->name,
                        'address' => $value->address,
                        'phone' => $value->phone,
                        ];
                        }

                if(!empty($insert)){

                    $insertData = DB::table('people')->insert($insert);
                    if ($insertData) {
                    Session::flash('success', 'Your Data has successfully imported');
                    }else {
                    Session::flash('error', 'Error inserting the data..');
                    return back();
                    }
                }
            }
                return back();
            }else {
                Session::flash('error', 'File is a '.$extension.' file.!! Please upload a valid xls/csv file..!!');
                return back();
            }
        }
    }

}

this is model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class People extends Model
{
    use Searchable;
    protected $guarded = [];
}

this is view:

<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">

    <title>Import</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <style>
    html, body {
        background-color: #fff;
        color: #636b6f;
        font-family: 'Raleway', sans-serif;
        font-weight: 100;
        height: 100vh;
        margin: 0;
        padding: 5%
    }
</style>
</head>
<body>
    <div class="container">


        <h2 class="text-center">
            Laravel Excel/CSV Import
        </h2>

        @if ( Session::has('success') )
        <div class="alert alert-success alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            <span class="sr-only">Close</span>
        </button>
        <strong>{{ Session::get('success') }}</strong>
    </div>
    @endif

    @if ( Session::has('error') )
    <div class="alert alert-danger alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            <span class="sr-only">Close</span>
        </button>
        <strong>{{ Session::get('error') }}</strong>
    </div>
    @endif

    @if (count($errors) > 0)
    <div class="alert alert-danger">
      <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
      <div>
        @foreach ($errors->all() as $error)
        <p>{{ $error }}</p>
        @endforeach
    </div>
</div>
@endif



<form action="{{ route('import') }}" method="POST" enctype="multipart/form-data">
    {{ csrf_field() }}
    Choose your xls/csv File : <input type="file" name="file" class="form-control">

    <input type="submit" class="btn btn-primary btn-lg" style="margin-top: 3%">
</form>

</div>
</body>
</html>

I'm using laravel 6

Feb
01
3 weeks ago
Activity icon

Started a new Conversation Importing Table

Hey Laravelers I imported excel sheet and it make table dynamically when I import it in the mysql database but I don't know how to view it in the page because I don't know how to call the fields and I don't know them early

Activity icon

Replied to Import Excel

@carpad88

You can see I mention it in my question

Activity icon

Started a new Conversation Import Excel

Hey Larvelers

I importing excel sheet with laravel excel and I want to do this:

public function upload(Filesystem $filesystem, $filePath)
{
    $path = str_random(20);
    $fullPath = public_path('temp/' . $path . '.csv');

    if ( ! mb_detect_encoding($filesystem->get($filePath), mb_detect_order(), true))
        $filesystem->put($filePath, chr(239) . chr(187) . chr(191) . utf8_encode($filesystem->get($filePath)));

    $filesystem->move($filePath, $fullPath);

    return $path;
}

for xls and xlsx instead of csv for the file path buth I don't know how

Activity icon

Started a new Conversation SPA Laravel Vue

Hey Laravelers

I create project in Laravel+Vue with three roles:

  1. admin
  2. manager
  3. customer

let's say I want the admin get full access for the datatable which means he can see three options (add, edit, delete). And the manager will see only (add and edit). Finally the customer only can see the (add) button how can I do that. Not to mention all of them accessing to the same page let's say I call it (index)

Activity icon

Commented on Database Configuration And Sequel Pro

I'm using mysql workbench in windows and it's so cool

Activity icon

Replied to XLSX, XLS

@ahmeddabak

Ok I'll try it and see what happen

Activity icon

Replied to XLSX, XLS

@ahmeddabak

I know about it and I'm using it but I need something else couldn't found it at it. It's the same for what I mention it up as the csv