lundi 21 décembre 2015

Auto creating data in db

I'm new in php and Laravel-5. I created project, which has DataController, Data model and it's connected to MySQL. Database has 2 columns: id and name. The problem: after page load need to auto-creation random amount of data to db. I want name to be a constant (name = "phone") + add it's id to the end (phone 1, phone 2 ...). Something like SELECT CONCAT(name, ' ', id) FROM table. I think this logic should be in controller, but I don't know how to auto-generate data.

class DataController extends Controller
{
    public function index() {
        $phones = Phone::all();
        return view('phones.index')-> with("phones", $phones);
    }

    public function store(Request $request) {
        $sheep = Sheep::Create();
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire